//
	if ((this.location.pathname=="/login" || this.location.pathname=="/logout") && (parent.location.pathname!="/login" && parent.location.pathname!="/logout")){
		parent.location.href="/logout";
	}
$(function() {


//	var resizeContext = function() {
//		setTimeout(function() {
//			var winHeight = 0;
//			if (window.innerHeight)
//				winHeight = window.innerHeight;
//			else if ((document.body) && (document.body.clientHeight))
//				winHeight = document.body.clientHeight;
//			var contentHeiht = winHeight - 138 - 48-20;
//			console.log(contentHeiht);
//			$("#content").attr("style", "height:" + contentHeiht + "px");
//		}, 10)
//	}
//	
//	$(window).bind("load", resizeContext);
//	$(window).bind("resize", resizeContext);
	
	
	//MESSAGE - TAG HIDE //
	$(".message").click(function() {
		if (!$(this).attr('thumbtack') || $(this).attr('thumbtack')==true){
			$(this).hide('blind', 500);
			return false;
		}
    });
	
	$(".datepicker").datepicker();
	
	$(".tag").click(function() {
                  $(this).hide('highlight', 500);
                  return false;
    });	
	

	
});

var MZ=new function (){
		
	this.isNumber = function(oNum) {
		if (!oNum)
			return false;
		var strP = /^\d+(\.\d+)?$/;
		if (!strP.test(oNum))
			return false;
		try {
			if (parseFloat(oNum) != oNum)
				return false;
		} catch (ex) {
			return false;
		}
		return true;
	};
	
	this.isBlank=function(value){
		if (!value || $.trim(value)==""){
			return true;
		}
		return false;
	};
	
	//打开/关闭DIALOG
	this.openDialog=function(dialogId){
		$('#'+dialogId).dialog('open');
	};
	
	
	this.closeDialog=function(dialogId){
		$('#'+dialogId).dialog('close');
	};
	
	
	//清空FORM
	this.clearForm=function(formId){
		$("#"+formId).clearForm();
	};
	
	//重新加载FLEXIGRID DATA
	this.reloadDatagrid=function(datagridId){
		$("#"+datagridId).flexOptions({newp: 1}).flexReload();
	};
	
	this.reset=function(searchFormId){
		$("#"+searchFormId)[0].reset();
	};
	
	this.searchGird=function(searchFormId,dataGirdId){
		var formParams=$('#'+searchFormId).serializeObject();
		var params=new Array();
		for (var key in formParams){
			var param={};
			param['name']=key;
			param['value']=formParams[key];
			params.push(param);
		}
		$("#"+dataGirdId).flexigrid().flexOptions({newp: 1, params: params}).flexReload();
	};
	
	this.showMsg=function(msg,title,type){
		//alert(msg);
		jAlert(msg, "系统提示");
	};
	
	/**
	 * 自动现象提示信息的ajax请求,json格式<br>
	 * 
	 * @param url
	 *            请求的URL
	 * @param data
	 *            请求的数据
	 * @param success
	 *            执行成功以后的回调函数
	 * @param failure
	 *            执行失败以后的回调函数
	 */
	this.ajaxShowMsg=function (op) {
		$.ajax({
			url : op.url,
			type : "post",
			data : op.data,
			success : function(result) {
				if (result.succeed) {
					if (op.success){
						op.success(result);
					}
				} else {
					if (op.failure){
						op.failure(result);
					}
				}
				MZ.showMsg(result.message);
			},
			error : function(result) {
				MZ.showMsg("网络异常");
			}
		});
	};
	
	//金额精度：W/分
	this.CURRENCY_PRECISION = 100;
	this.CURRENCY_ROUND = 6;
	this.BRANCH_COST_VERIFY = "branchCost_01";
	this.COMPANY_COST_VERIFY = "companyCost_01";

	//精确到E位显示数值
	this.toDecimal =function (x, e) {  
	    var t=1;
	    //var e=1;
	    for(;e>0;t*=10,e--);
	    for(;e<0;t/=10,e++);
	    return Math.round(x*t)/t;
	}
};

